package org.gongzhen.HomeMapper;

import org.apache.ibatis.annotations.*;
import org.gongzhen.Category;
import org.gongzhen.Post;

import java.util.List;

@Mapper
public interface PostMapper {

    @Select("select * from schoolwall.post")
    List<Post> getAllPost();

    @Delete("delete from post where id = #{id}")
    void delete(Integer id);

    @Insert("insert into post" +
            "(user_id, content, images, tags, location, category_id," +
            "view_count, comment_count, share_count, like_count, collection_count, create_time, update_time) " +
            "values (#{userId}, #{content}, #{images}, #{tags}, #{location}, #{categoryId}," +
            "#{viewCount}, #{commentCount}, #{shareCount}, #{likeCount}, #{collectionCount}, #{createTime}, #{updateTime})")
    void insert(Post post);

    void update(Post post);

    @Select("select * from post where id = #{id}")
    Post getById(Integer id);


    @Select("select * from post where category_id = #{categoryId}")
    List<Post> getByCategoryId(Integer categoryId);
}
